home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Demos / Bowers Development / AppMaker 2.0b5 / Examples / PowerPlant / Gadgets / CButtons.cp < prev    next >
Encoding:
Text File  |  1996-03-19  |  3.6 KB  |  186 lines  |  [TEXT/CWIE]

  1. // CButtons.cp -- window methods
  2. // Created 3/19/96 12:49 PM by AppMaker
  3.  
  4. #include "CButtons.h"
  5.  
  6. #include <UReanimator.h>
  7. #include <URegistrar.h>
  8. #include <LStream.h>
  9. #include <CInvisibleButton.h>
  10. #include <LStdControl.h>
  11. #include "CGadgetsData.h"
  12. #include "CmdCodes.h"
  13.  
  14. #define PPob_ButtonsID    200
  15. #define RidL_ButtonsID    200
  16.  
  17. Boolean        CButtons::sIsRegistered = false;
  18.  
  19. //----------
  20. void
  21. CButtons::RegisterClass ()
  22. {
  23.     URegistrar::RegisterClass ('Buts', (ClassCreatorFunc)CButtons::CreateButtonsStream);
  24.  
  25.     // register the pane classes we use
  26.     CInvisibleButton::RegisterClass ();
  27.  
  28.     sIsRegistered = true;
  29. }
  30.  
  31. //----------
  32. CButtons*
  33. CButtons::CreateButtons(
  34.     LCommander            *inSuperCommander,
  35.     CGadgetsData        *inData)
  36. {
  37.     if (!sIsRegistered) {
  38.         RegisterClass ();
  39.     }
  40.  
  41.     CButtons        *window;
  42.  
  43.     window = (CButtons *)LWindow::CreateWindow(PPob_ButtonsID, inSuperCommander);
  44.     window->ConnectToData (inData);
  45.  
  46.     return window;
  47. }
  48.  
  49. //----------
  50. //    This is the function you register with URegistrar to create a
  51. //    CButtons from a resource
  52.  
  53. CButtons*
  54. CButtons::CreateButtonsStream(
  55.     LStream    *inStream)
  56. {
  57.     return (new CButtons(inStream));
  58. }
  59.  
  60. //----------
  61. CButtons::CButtons()
  62. {
  63. }
  64.  
  65. //----------
  66. CButtons::CButtons(
  67.     LStream    *inStream)
  68.         : LWindow(inStream)
  69. {
  70. }
  71.  
  72. //----------
  73. CButtons::~CButtons()
  74. {
  75. }
  76.  
  77. //----------
  78. //    This member function gets called once the containment hierarchy that contains
  79. //    this pane has been built. It gives us a chance to get data members for
  80. //    interesting subviews, and to do other operations now that our subviews exist.
  81. void
  82. CButtons::FinishCreateSelf()
  83. {
  84.     mInvisibleButton = (CInvisibleButton *)FindPaneByID ('Inv2');
  85.     mOKButton = (LStdButton *)FindPaneByID ('OK  ');
  86.     mX3DButton = (LStdButton *)FindPaneByID ('X3D ');
  87.     mPictButtonButton = (LStdButton *)FindPaneByID ('Picn');
  88.     mTitledPictButton = (LStdButton *)FindPaneByID ('Titt');
  89.     mCheckCheck = (LStdCheckBox *)FindPaneByID ('Chek');
  90.     mX3DRadioRadio = (LStdRadioButton *)FindPaneByID ('X3Do');
  91.     mPictCheckCheck = (LStdCheckBox *)FindPaneByID ('Pick');
  92.     mX3DCheckCheck = (LStdCheckBox *)FindPaneByID ('X3Dk');
  93.  
  94.     UReanimator::LinkListenerToControls(this, this, RidL_ButtonsID);
  95.         // the purpose is to "connect" self to whatever controls
  96.         // that we want to "listen" to
  97.  
  98. // any additional initialization for your window:
  99.  
  100. }
  101.  
  102. //----------
  103. void
  104. CButtons::ConnectToData    (CGadgetsData        *inData)
  105. {
  106.     mData = inData;
  107.     inData->AddListener (this);
  108. }
  109.  
  110. //----------
  111. void
  112. CButtons::ListenToMessage(
  113.     MessageT    inMessage,
  114.     void        *ioParam)
  115. {
  116.     switch (inMessage) {
  117.  
  118.     default:
  119.         break;
  120.     }
  121. }
  122.  
  123. //----------
  124. Boolean
  125. CButtons::ObeyCommand(
  126.     CommandT    inCommand,
  127.     void        *ioParam)
  128. {
  129.     Boolean        cmdHandled = true;
  130.  
  131.     switch (inCommand) {
  132.  
  133.     // +++ Add cases here for the commands you handle
  134.     //        Remember to add same cases to FindCommandStatus below
  135.     //        to enable/disable the commands
  136.  
  137.     default:
  138.             cmdHandled = LWindow::ObeyCommand(inCommand, ioParam);
  139.         break;
  140.     }
  141.  
  142.     return cmdHandled;
  143. }
  144.  
  145. //----------
  146. void
  147. CButtons::FindCommandStatus(
  148.     CommandT    inCommand,
  149.     Boolean        &outEnabled,
  150.     Boolean        &outUsesMark,
  151.     Char16        &outMark,
  152.     Str255        outName)
  153. {
  154.     outUsesMark = false;
  155.  
  156.     switch (inCommand) {
  157.  
  158.     // +++ Add cases here for the commands you handle
  159.  
  160.     default:
  161.             LWindow::FindCommandStatus(inCommand, outEnabled,
  162.                                         outUsesMark, outMark, outName);
  163.         break;
  164.     }
  165. }
  166.  
  167. //----------
  168. Boolean
  169. CButtons::FocusDraw()
  170. {
  171.     Boolean        focused = LView::FocusDraw();
  172.  
  173.     if (focused) {
  174.         AuxWinHandle    awHndl;
  175.         CTabHandle        awCTable;
  176.         ColorSpec        contentSpec;
  177.  
  178.         GetAuxWin(GetMacPort(), &awHndl);
  179.         awCTable = (**awHndl).awCTable;
  180.         contentSpec = (**awCTable).ctTable [wContentColor];        // should search vs. index
  181.         ::RGBBackColor(&contentSpec.rgb);
  182.     }
  183.  
  184.     return focused;
  185. }
  186.